import 'package:enterprise_v6_app/app/components/video/video_play_widget.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/data/entities/application/emergency/exercise_plan_entity.dart';
import 'package:enterprise_v6_app/app/modules/application/emergency/drill/drill_details/drill_results/drill_results_controller.dart';

/// 演练结果
class DrillResultsPage extends StatelessWidget {
  DrillResultsPage({required this.entity, super.key});

  /// 数据实体
  final ExercisePlanEntity entity;

  final controller = Get.put(DrillResultsController());

  @override
  Widget build(BuildContext context) {
    return GetBuilder(
      init: controller,
      builder: (_) {
        return Container(
          alignment: Alignment.topCenter,
          color: Colors.white,
          child: Column(
            children: [
              Container(
                height: 175.w,
                alignment: Alignment.center,
                child: const VideoPlayWidget(
                  // url: 'https://www.runoob.com/try/demo_source/movie.mp4',
                  url: '',
                  autoPlay: true,
                ),
              ),
              Container(
                height: 10.w,
                color: const Color(0xffEEF0FF),
              ),
              Expanded(
                  child: Container(
                padding: EdgeInsets.all(20.w),
                child: SingleChildScrollView(
                  child: Column(
                    children: [
                      Row(
                        children: [
                          Container(
                            height: 14.w,
                            width: 3.w,
                            decoration: BoxDecoration(
                              color: Colors.white,
                              borderRadius:
                                  BorderRadius.only(topRight: Radius.circular(90.w), bottomLeft: Radius.circular(20.w), bottomRight: Radius.circular(20.w)),
                              gradient: LinearGradient(
                                  //渐变位置
                                  begin: Alignment.topCenter,
                                  end: Alignment.bottomCenter,
                                  //渐变颜色[始点颜色, 结束颜色]
                                  colors: [const Color(0xff587DF5), const Color(0xff587DF5), const Color(0xff587DF5).withOpacity(0.6)]),
                            ),
                          ),
                          AppGaps.hGap10,
                          Text(
                            '总结',
                            style: TextStyle(
                              fontSize: 16.sp,
                              height: 1.2,
                              fontWeight: FontWeight.w500,
                              color: const Color(0xff262F38),
                            ),
                          ),
                        ],
                      ),
                      AppGaps.vGap16,
                      _getTextViewWidget(title: '演练过程', value: entity.exerciseProcess),
                      AppGaps.vGap20,
                      _getTextViewWidget(title: '演练效果评估', value: entity.exerciseEstimate),
                      AppGaps.vGap20,
                      _getTextViewWidget(title: '存在问题', value: entity.existingProblems),
                      AppGaps.vGap20,
                      _getTextViewWidget(title: '改进措施', value: entity.improvementMeasures),
                    ],
                  ),
                ),
              )),
            ],
          ),
        );
      },
    );
  }

  /// 获取内容显示
  Widget _getTextViewWidget({required String title, required String value}) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          title,
          style: TextStyle(
            fontSize: 14.sp,
            height: 1.2,
            fontWeight: FontWeight.w500,
            color: const Color(0xff262F38),
          ),
        ),
        AppGaps.vGap10,
        Container(
          padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 10.w),
          decoration: BoxDecoration(
            color: const Color(0xffF7F7FB),
            border: Border.all(
              color: const Color(0xffEBEDF0),
              width: 1.w,
            ),
            borderRadius: BorderRadius.circular(8.r),
          ),
          constraints: BoxConstraints(
            minHeight: 68.w,
          ),
          alignment: Alignment.topLeft,
          child: Text(
            value,
            style: TextStyle(
              fontSize: 14.sp,
              height: 1.2,
              fontWeight: FontWeight.w400,
              color: const Color(0xFF262F38),
            ),
          ),
        ),
      ],
    );
  }
}
